package Plugins::MLBGameday::Plugin;

# SqueezeCenter Copyright 2001-2008 Logitech.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

use strict;
use warnings;

use Plugins::MLBGameday::Schedule;
use Plugins::MLBGameday::Settings;
use Slim::Buttons::Common;
use Slim::Buttons::XMLBrowser;
use Slim::Utils::Prefs;
use Slim::Utils::Strings qw( string );

use base qw(Slim::Plugin::Base);

my $log = Slim::Utils::Log->addLogCategory
    ({
        'category'     => 'plugin.mlbgameday',
        'defaultLevel' => 'INFO',
        'description'  => getDisplayName(),
    });

sub initPlugin {
    my $class = shift;

    $class->SUPER::initPlugin();

    Plugins::MLBGameday::Settings->new();
}

sub getDisplayName {
    return 'PLUGIN_MLBGAMEDAY_MODULE_NAME';
}

sub setMode {
    my $class  = shift;
    my $client = shift;
    my $method = shift;
    
    if ($method eq 'pop') {
        Slim::Buttons::Common::popMode($client);
        return;
    }

    my $params = {
        header   => 'PLUGIN_MLBGAMEDAY_LOADING',
        modeName => 'MLBGameday Plugin',
        url      => \&Plugins::MLBGameday::Schedule::getScheduleCallback,
        title    => $client->string(getDisplayName()),
    };

    Slim::Buttons::Common::pushMode($client, 'xmlbrowser', $params);

    # we'll handle the push in a callback
    $client->modeParam('handledTransition', 1);
}

1;

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
